<#include "/common/head.html"/> 
<table id="dg"></table>
<div id="tb" style="padding:2px 5px;">
     	<a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">添加规则类型</a> 
        <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="delete1()">删除</a>
</div>
<script type="text/javascript">
var datagrid = $("#dg");
var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
    	singleSelect:true,
//         queryParams: getInitParam(),
        columns: [[
				{field:'id', title:'序号', width:100}
	           	 ,{field:'type', title: '规则类型', width:100}
	           	
	           ]]
	};
$(function() {
	datagrid.datagrid(dgOptions);
});

function add() {
	location.replace('add2');
}
function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var activityid = rowsSel[0].activityid;
	location.replace('updatePage?activityid='+activityid);
}

function delete1() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var activityid = rowsSel[0].activityid;
	confirmMsg("确认删除吗？", function() {
/* 		var bb="";
		for (var i = 0; i < rowsSel.length; i++) {
			var aa = rowsSel[i].positionid;
			bb = aa + "|" +bb;
		} */
		var activityid = rowsSel[0].activityid;
		$.post("delete", {activityid: activityid}, function(data) {
			var result = data.result;
			if(result=='success'){
				showMsg("删除成功！");
				datagrid.datagrid("reload");
			}else{
				showWarnMsg(result);
        		return;
			}
		});
	});
}

function cancelAudit() {
	var rowsSel = datagrid.datagrid("getSelections");
 	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	} 
 	var activityid = rowsSel[0].activityid;
	location.replace('adcurationPage?activityid='+activityid);
}

//var s_time = 0;
function zcurdSearch() {
	var param = zcurdGetParam();
	//if(s_time==0){
	//	datagrid.datagrid(dgOptions);
	//	s_time++;
	//}else{
		datagrid.datagrid("load", param);
	//}
}

function zcurdGetParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param[$(item).attr("name")] = $(item).val().trim();	
		}
	});
	return param;
}

/* 
function formattype(value,row,index){
	if(value == 0){
		return "图片";
	}else if(value == 1){
		return "文字";
	}
} */

function formatstate(value,row,index){
	if(value == 0){
		return "启用";
	}else if(value == 1){
		return "禁用";
	}
}
</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>